﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Framework;
using OLTS.DAL;
using OLTS.MODEL;

namespace OLTS.DATA_SERVICE
{
    public class Approval_Service
    {
        private OTS_APPROVED _objApp = new OTS_APPROVED();

        public Approval_Service(OTS_APPROVED objApp)
        {
            _objApp = objApp;
        }

        public Approval_Service()
        {

        }

        public List<OTS_APPROVED> GetAll()
        {
            using (var ctx = new Entities())
            {
                var list = ctx.OTS_APPROVED.ToList();
                return list;
            }
        }

        public void GetAllinclude()
        {

        }

        public void Edit()
        {
            using (var ctx = new Entities())
            {
                var obj = ctx.OTS_APPROVED.Where(x => x.ID == _objApp.ID).FirstOrDefault();
                obj.SEQ = _objApp.SEQ;
                obj.APPROVED_BY = _objApp.APPROVED_BY;
                obj.POSITION = _objApp.POSITION;
                ctx.SaveChanges();
            }
        }

        public void Add()
        {
            using (var ctx = new Entities())
            {
                ctx.OTS_APPROVED.AddObject(_objApp);
                ctx.SaveChanges();
            }
        }

        public void Delete()
        {
            using (var ctx = new Entities())
            {
                var obj = ctx.OTS_APPROVED.Where(x => x.ID == _objApp.ID).FirstOrDefault();
                ctx.OTS_APPROVED.DeleteObject(obj);
                ctx.SaveChanges();
            }
        }

    }
}
